/*************************************************************************
 * @file: kvje.cpp
 * @date: 01/04/2012
 * TOPOL v1_0 - (c)copyright 2012 TEC/UFF
 *************************************************************************
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 ************************************************************************/

// includes
//----------
#include "kvje.h"
#include <iostream>
#include "../entity/solid.h"
#include "../entity/face.h"
#include "../entity/loop.h"
#include "../entity/vertex.h"
#include "../entity/halfedge.h"
#include "../entity/edge.h"
#include "../entity/ipoint.h"



///////////////////////////////////////////////////
///  Constructor and Destructor Implementation  ///
///////////////////////////////////////////////////

//-------------------------------------------------------------------------
KVJE::KVJE( Vertex* _v )
: m_vertex( _v )
{

}
//-------------------------------------------------------------------------



///////////////////////////////////////
///  PUBLIC Methods Implementation  ///
///////////////////////////////////////

//-------------------------------------------------------------------------
void
KVJE::execute()
{
  std::cout << "\nKVJE::execute() \n";
  HalfEdge* he1 = m_vertex->getVEdge();
  HalfEdge* he2 = he1->mate()->getNxt();
  Edge* e1 = he1->getEdg();
  Edge* e2 = he2->getEdg();
  Loop* loop1 = he1->getLoop();
  Loop* loop2 = he2->getLoop();
  Solid* solid = loop1->getFace()->getSolid();

  if( e2->getHe1() != he2 )
    e2->setHe2( he1->mate() );
  else
    e2->setHe1( he1->mate() );

  he1->mate()->setEdg( e2 );
  he1->mate()->getVtx()->setVedge( he1->mate() );

  delete e1;
  delete m_vertex;

  loop1->setLedg( he1->delhe() );
  loop2->setLedg( he2->delhe() );
}
//-------------------------------------------------------------------------

//-------------------------------------------------------------------------
void
KVJE::unExecute()
{
  std::cout << "\nKVJE::unExecute() NOT IMPLEMENTED!\n";
}
//-------------------------------------------------------------------------







